var temp = {
    error:'',
    data:'',
    success:''
};

let con = require('./sql_main');

let  addSql = 'INSERT INTO temp_table(temp,time) VALUES(?,?)';
let  addParams = ['34.9','2017-11-13 15:58:32'];
let  count =1;

//只有第一次加载了，再次加载时感觉直接把是、结果输出，没有进行再一次js计算
console.log('Connect Count:',count);

con.connect();

con.query(addSql,addParams,function(err,result){
    if(err){
        console.log('[INSERT ERROR] - ',err.message);
        temp.error = err.message;
        temp.success = false;
        return;
    }
    temp.success = true;
    console.log('--------------------------INSERT----------------------------');
    //console.log('INSERT ID:',result.insertId);
    console.log('INSERT ID:',result);
    console.log('-----------------------------------------------------------------\n\n');
    con.end();
});


module.exports = temp;